##############################################################
# CMakeLists.txt for a ROS package within the low-cost-vision
# build system. 
# 
# Created by Pascal Muller <pascalmuller@gmail.com>, 09-02-2012
# 
# 09-02-2012 Initial version
# 
#############################################################

cmake_minimum_required(VERSION 2.4.6)
# Include all rosbuild macros
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# If the vision target does not exists, target_location is set to a value that is handled as false. 
get_target_property(target_location vision LOCATION) 

# If the vision target can't be built, we need to disable this one too :) 
if(target_location AND Boost_FOUND) # vision target exists
	# Initialize ROS package to be in our build system. 
	lcv_rospack_init("cratedemo" true false)

	# Add executables as documented by ROS
	file(GLOB sources src/*.cpp)
	rosbuild_add_executable(cratedemo ${sources})

	# Add dependencies to our libraries and other ROS packages in the same directory as this one. 
	add_dependencies(cratedemo deltarobot vision grippernode xml_io)

	# Include libraries
	include_directories(${Boost_INCLUDE_DIRS} ${LIB_DATATYPES_INCLUDE} ${LIB_XMLIO_INCLUDE})

	# Link target to our libraries
	target_link_libraries(cratedemo xml_io ${Boost_THREAD_LIBRARY})
	
	# Unfortunately, in some cases rosbuild messes up and therefore we should set the include 
	# directories by hand; only uncomment this if you get in to trouble and don't commit the change!
	#include_directories(../vision/srv_gen/cpp/include)
	#include_directories(../deltarobotnode/srv_gen/cpp/include)

	# MUST be called after lcv_rospack_init to clean up after ROSBUILD!
	lcv_rospack_end()
else(target_location AND Boost_FOUND) # vision target does not exist
	lcv_cannot_build(cratedemo, "ROS/cratedemo")
endif(target_location AND Boost_FOUND)

